package assignmentOne.thoughtworks;

/**
 * Created by derekgliwa on 6/15/14.
 */
public class PrimeFactor {
    public static void main(String[]args){
        generate(1);
        generate(30);
    }

    public static void generate(int n){
        if(n==1){
            return;
        }
        if(n%2==0){
            System.out.print(2 + ",");
            generate(n/2);
        }
        else if(n%3==0){
            System.out.print(3 + ",");
            generate(n/3);
        }
        else{
        for(int i = 5; i<=n; i+=2){
            if(n%i == 0){
                System.out.print(i+",");
                generate(n/i);
            }
        }
        }
    }
}
